package com.sloth.service.impl;

import com.sloth.mapper.ReviewMapper;
import com.sloth.mapper.ReviewReplyMapper;
import com.sloth.pojo.Review;
import com.sloth.pojo.ReviewExample;
import com.sloth.service.ReviewService;
import com.sloth.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReviewServiceImpl implements ReviewService {
    @Autowired
    private ReviewMapper reviewMapper;

    @Autowired
    private ReviewReplyMapper reviewReplyMapper;

    @Override
    public ServerResponse getById(Integer proId) {
        ReviewExample reviewExample=new ReviewExample();
        reviewExample.createCriteria().andProIdEqualTo(proId);
        List<Review> reviewList=reviewMapper.selectByExample(reviewExample);
        if (reviewList.size()>0){
            return ServerResponse.getSuccess(reviewList);
        }
        return ServerResponse.getFail(null);

    }
}
